<?php
// 链接数据库
$mysqli = @new mysqli("127.0.0.1", "root", "root", "school");

if($mysqli->connect_errno){
	exit('链接数据库失败,错误代码：'.$mysqli->connect_errno.',错误原因：'.$mysqli->connect_error);
}
// 设置客户端编码
$mysqli->query('set names utf8');

// $sql = "insert into stu (sname,age,sex) values(?,?,?)";

// $res  = $mysqli->prepare($sql);

// var_dump($res);exit;


$sql = "update stu set age=20 where sname='小明'";

$sql = "select * from stu order by age";
// 执行sql
$res = $mysqli->query($sql);

if(!$res){
	exit('错误代码：'.$mysqli->errno.',错误原因：'.$mysqli->error);
}

$arr = [];
// 取结果集中的数据
while($row=$res->fetch_assoc()){
	$arr[] = $row;
}
// var_dump($res->fetch_row());
// var_dump($res->fetch_assoc());
// var_dump($res->fetch_assoc());
// var_dump($res->fetch_assoc());
// var_dump($res->fetch_assoc());
// var_dump($res->fetch_object());
// var_dump($res->fetch_array());


var_dump($arr);

$res->free();

$mysqli->close();